package com.hu.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hu.common.core.page.TableDataInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hu.common.annotation.Log;
import com.hu.common.core.controller.BaseController;
import com.hu.common.enums.BusinessType;
import com.hu.system.domain.StockRecord;
import com.hu.system.service.IStockRecordService;
import com.hu.common.utils.poi.ExcelUtil;

/**
 * 库存记录Controller
 *
 * @author hu
 * @date 2025-01-22
 */
@RestController
@RequestMapping("/business/stock/record")
public class StockRecordController extends BaseController {
    @Autowired
    private IStockRecordService stockRecordService;

    /**
     * 查询库存记录列表（合并入库和出库）
     */
    @PreAuthorize("@ss.hasPermi('stock:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(StockRecord stockRecord) {
        startPage();
        List<StockRecord> list = stockRecordService.selectStockRecordList(stockRecord);
        return getDataTable(list);
    }

    /**
     * 导出库存记录列表
     */
    @PreAuthorize("@ss.hasPermi('stock:record:export')")
    @Log(title = "库存记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StockRecord stockRecord) {
        List<StockRecord> list = stockRecordService.selectStockRecordList(stockRecord);
        ExcelUtil<StockRecord> util = new ExcelUtil<StockRecord>(StockRecord.class);
        util.exportExcel(response, list, "库存记录数据");
    }
}

